<template>
	<view class="wrap yjfk-form-right">
		<u-form class="form" :model="model" :rules="rules" ref="uForm" label-position="top">
			<u-form-item label="问题和意见" prop="content">
				<u-input type="textarea" placeholder="请填写10个字以上的问题描述以便我们提供更好的帮助" v-model="model.content" height="200"
					maxlength="500" />
			</u-form-item>
			<u-form-item label="联系方式（手机、邮箱、QQ号码）" prop="contact">
				<u-input class="input-left-form" placeholder="选填，便于我们与你联系，进一步沟通" v-model="model.contact" type="text"
					maxlength="200" />
			</u-form-item>
		</u-form>
		<view class="form-footer">
			<u-button class="btn" type="primary" @click="submit">提交</u-button>
			<u-button class="btn" type="default" @click="cancel">关闭</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				model: {
					id: '',
					category: '',
					content: '',
					contact: '',
					deviceInfo: ''
				},
				rules: {
					category: [{
						required: true,
						message: '请选择问题和意见的分类',
						trigger: ['change', 'blur'],
					}],
					content: [{
						required: true,
						min: 10,
						max: 500,
						message: '问题和意见在 10 到 500 个字符之间',
						trigger: ['change', 'blur'],
					}],
				}
			};
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
			// 获取设备信息
			uni.getSystemInfo({
				success: res => {
					this.model.deviceInfo = JSON.stringify(res);
				}
			});
		},
		methods: {
			submit() {
				// console.log(this.model)
				this.$u.toast('提交成功')
			},
			cancel() {
				uni.navigateBack();
			}
		}
	};
</script>

<style lang="scss" scoped>
	.input-placeholder {
		text-align: right;
	}
</style>
